user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  3000;
}

stream {
    upstream apiservers {
{% for master in groups['kube_master'] %}
        server {{ master }}:{{ APISERVER_SECURE_PORT }} max_fails=2 fail_timeout=3s;
{% endfor %}
    }

    server {
        listen {{ APISERVER_LB_IP }}:{{ APISERVER_LB_PORT }};
        proxy_connect_timeout 3s;
        proxy_pass apiservers;
    }
}